package com.example.springmybatisservice.controller;
import com.example.springmybatisservice.PageRequest;
import com.example.springmybatisservice.User;
import com.example.springmybatisservice.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wuxinxin
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/one/{userId}")
    public List<User> getOne(@PathVariable Integer userId){
        return userService.getOne(userId);
    }

    @GetMapping
    public PageInfo<User> list(PageRequest pageRequest){
        return userService.list(pageRequest);
    }

    @PostMapping
    public void addTestData(){
        userService.addTestData();
    }
}
